<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    
<ul class="list">
    <li>li 1</li>
    <li>li 2</li>
    <li>li 3</li>
    <li>li 4</li>
</ul>

<script>
// Array.from()方法，将含有length属性，并且以数字作为key的对象或类数组对象转成真正的数组

let lis = document.querySelectorAll('.list li');
// console.log( lis );
// lis.push('li4');// 报错

let likeArray = {
    0: 'a1',
    1: 'a2',
    2: 'a3',
    3: 'a4',
    length: 4
}
// console.log( likeArray );
// likeArray.push('a5');// 报错

lis = Array.from(lis);
console.log( lis );// [li, li, li, li]

likeArray = Array.from(likeArray);
console.log( likeArray );// ['a1', 'a2', 'a3', 'a4']

</script>
</body>
</html>